<?php

namespace app\command;
use think\App;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use app\order\logic\ReamazeLogic;
use app\order\logic\CheckbillLogic;
use app\api\logic\TestLogic;
use app\order\logic\DisputesLogic;
use app\order\logic\OrderLogic;
use think\facade\Cache;
class DisputesConsummer extends Command
{

        protected function configure()
        {
                $this->setName('DisputesConsummer')
                ->setDescription('DisputesConsummer');
        }

        protected function execute(Input $input, Output $output)
        {
                //拉取数据--更新争议状态
                //disputeapi---只跑17号店铺---更新状态--前200页
                (new OrderLogic())->UpdateStatusdisputeapi();
                //争议数据对应到订单Afterpay---只跑17号店铺---更新状态--200页
                (new OrderLogic())->AfterpayHistory();
                //云汇
                (new OrderLogic())->get_airwallex_list();
                // Paypal 暂定 https://fun.newshopify.com/api/ApiOrderDispute/dispute_paypal?type=1
                // Stripe 暂定 https://fun.newshopify.com/api/ApiOrderDispute/dispute_stripe?type=1

                //更新平台状态
                // transactions总交易在ReamazeConsummer
                // reamazelabel总会话在ReamazeConsummer 
                
                //争议统计
                (new OrderLogic())->DisputeStatistics();
                //shopify payment
                (new OrderLogic())->DisputeToOrdersShopify();
                //云汇
                (new OrderLogic())->DisputeToOrdersAirwallex();
                //争议数据对应到订单Paypal
                (new OrderLogic())->DisputeToOrdersPaypal();
                //争议数据对应到订单Stripe
                (new OrderLogic())->DisputeToOrdersStripe();
                //争议数据对应到订单Afterpay
                (new OrderLogic())->DisputeToOrdersAfterpay();
                
                //2天更新一次
                $ExpirationDate = Cache::store('redis')->get('DisputesConsummer');
                if (empty($ExpirationDate)) {  
                        Cache::store('redis')->set('DisputesConsummer', 1, 3600 * 24 * 1);
                }else{
                        echo '时间没到先不更新';die;
                }

                (new OrderLogic())->Apireamaze();

                (new OrderLogic())->dispute_status_update();

        }
}